package kuanshu.controller;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.ChatClient;
import org.springframework.ai.chat.ChatResponse;
import org.springframework.ai.chat.messages.UserMessage;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@CrossOrigin("*")
@RestController
@RequestMapping("/deepseek")
public class DeepSeekController {
    @Resource
    private ChatClient chatClient;

    @RequestMapping("/kefu")
    public String ask(@RequestParam("wenti") String wenti) {
        System.out.println(wenti);
        Prompt prompt = new Prompt(new UserMessage(wenti));
        ChatResponse response = chatClient.call(prompt);
        return response.getResult().getOutput().getContent();
    }
}